//
//  MyNavigationController.m
//  4、自定义导航栏控制器和TabbarController
//
//  Created by niit on 15/5/7.
//  Copyright (c) 2015年 niit. All rights reserved.
//

#import "MyNavigationController.h"

@interface MyNavigationController ()

@end

@implementation MyNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

//initialize在创建对象的时候会调用该方法，而且该方法无论创建多少个对象，只会执行一次
+(void)initialize{
//1、设置导航栏主题(只要设置了这个appearance,那么所有的继承于本类的导航栏对象都会使用这个appearance)
    UINavigationBar *naviBar=[UINavigationBar appearance];
//    NSString *bgImage=@"NavBar64";
//    naviBar.tintColor=[UIColor whiteColor];//设置返回箭头的颜色
//    [naviBar setBackgroundImage:[UIImage imageNamed:bgImage] forBarMetrics:UIBarMetricsDefault];
    naviBar.barStyle=UIBarStyleBlack;
    
//2、设置导航栏中间标题文字的字体、颜色
    NSMutableDictionary *attrs=[[NSMutableDictionary alloc]init];
    attrs[NSForegroundColorAttributeName]=[UIColor whiteColor];
    attrs[NSFontAttributeName]=[UIFont systemFontOfSize:26];
    [naviBar setTitleTextAttributes:attrs];
    
//3、设置导航栏左侧或者右侧BarButtonItem的主题
    UIBarButtonItem *item=[UIBarButtonItem appearance];
    NSMutableDictionary *attrs1=[[NSMutableDictionary alloc]init];
    attrs1[NSForegroundColorAttributeName]=[UIColor whiteColor];
    attrs1[NSFontAttributeName]=[UIFont systemFontOfSize:16];
    [item setTitleTextAttributes:attrs1 forState:UIControlStateNormal];
    
}

//重写父类的pushViewController：这个方法
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    viewController.hidesBottomBarWhenPushed=YES;
    [super pushViewController:viewController animated:animated];
}



@end
